﻿<div class="tabbable">
    <ul class="nav nav-tabs" id="myTab">
        <li class="active">
            <a data-toggle="tab" href="#tab1">考场场次</a>
        </li>
        <li class="tab-red">
            <a data-toggle="tab" href="#tab2">增加</a>
        </li>
    </ul>

    <div class="tab-content">
        <div id="tab1" class="tab-pane active">
            <div role="grid" id="editabledatatable_wrapper" class="dataTables_wrapper form-inline no-footer">
				<table class="table table-striped table-hover table-bordered dataTable no-footer" id="editabledatatable" aria-describedby="editabledatatable_info">
					<thead class="bordered-bottom-1 bordered-orange">
					<tr>
						<th class="text-center">ID</th>
						<th class="text-center">考试班级</th>
						<th class="text-center">开考时间</th>
						<th class="text-center">操作</th>
					</tr>
					</thead>
					<tbody>
					<?php
					if( empty( $exam ) ):
					?>
					<tr>
						<th colspan="4" class="text-center">当前没有考试场次！</th>
					</tr>
					<?php
					else:
						foreach( $exam as $m ):?>
					<tr>
						<td class="text-center"><?=$m['id'];?></td>
						<td class="text-center">
							<a href="<?=site_url( 'exam/watch').'/'.$m['id'] ;?>"><?=$m['cname'];?></a>
						</td>
						<td class="text-center"><?=$m['time'];?></td>
						<td class="text-center" style="width: 200px;">
							<button class="btn btn-info btn-xs edit" onclick="show_modal( 'modal', '<?=site_url( 'exam/edit_exam') . '/' .$m['id'];?>')"><i class="fa fa-pencil"></i> 编辑</button>
							<button class="btn btn-danger btn-xs delete" onclick="bb_confirm( '确定要删除【<?=$m['class'];?>】的考试安排？', '<?=site_url('exam/del_exam'). '/' .$m['id'];?>')"><i class="fa fa-trash-o"></i> 删除</button>
						</td>
					</tr>
					<?php
						endforeach;
					endif;
					?>
					</tbody>
				</table>
			</div>
        </div>

        <div id="tab2" class="tab-pane">
			<form class="form">
				<div class="form-group clearfix form-bordered">
					<label class="control-label col-md-1">考试班级</label>
					<select name="class" id="class">
					<?php foreach( $class as $c ):?>
						<option value="<?=$c['cid'];?>"><?=$c['cname'];?></option>
					<?php endforeach; ?>
					</select>
				</div>
				<div class="form-group clearfix form-bordered">
					<label class="control-label col-md-1">开考时间</label>
					<div class="col-md-11">
						<div class="form-group">
							<input type="datetime-local" class="form-control" name="time" id="time" step="1" placeholder="如果没有显示时间日期选择，请换用【谷歌】浏览器">
						</div>
					</div>
				</div>
				<div class="form-group text-right clearfix">
					<button class="btn btn-success" type="button" id="add_exam"><i class="fa fa-plus"></i>添加</button>
					<button type="reset" class="btn btn-default" onclick="window.location.reload()">取消</button>
				</div>
			</form>
            <div class="clearfix"></div>
        </div>
    </div>
</div>
<script>
$('#add_exam').click(function(){
	var input_time = $("#time").val();
	var time = input_time.replace( /T/, ' ' );
	ajax_post(
		'<?=site_url( 'exam/add_exam' );?>',
		{
			class:$("#class").val(),
			time:time,
		}
	);}
);
</script>